const App = require('./app')
const authRouter = require('./routers/auth.router')
const userRouter = require('./routers/user.router')
const reportRouter = require('./routers/report.router')
const registrationRouter = require('./routers/registration.router')
const placeRouter = require('./routers/place.router')
const messageRouter = require('./routers/message.router')
const typeRouter = require('./routers/type.router')
const areaRouter = require('./routers/area.router')
const fileRouter = require('./routers/file.router')
const logRouter = require('./routers/log.router')
const itemRouter = require('./routers/item.router')
const configRouter = require('./routers/config.router')
const statisticsRouter = require('./routers/statistics.router')

const schedule = require('node-schedule')
const logger = require('./utils/logger')
const checkDailyReports = require('./tasks/report.task')

require('./utils/prototype')

App([authRouter, userRouter, reportRouter, registrationRouter, placeRouter, messageRouter, typeRouter, areaRouter, fileRouter, logRouter, itemRouter, configRouter, statisticsRouter])

const scheduleCronstyle = () => {
  // 每天凌晨2点执行一次
  schedule.scheduleJob({ hour: 2, minute: 0, second: 0 }, () => {
    logger.info('start schedule task ')
    checkDailyReports()
  })
}

scheduleCronstyle()